                <div class="art-content-layout">
                    <div class="art-content-layout-row">
                        <div class="art-layout-cell art-content">
                            <div class="art-post">
                                <div class="art-post-body">
                                <div class="art-menu-2">Ngày: <?php echo date('d/m/Y'); ?></div>
                                    <div class="cleared"></div>
                                </div>
                            </div>
                            <div class="art-post">
                                <div class="art-post-body">
                            <div class="art-post-inner art-article">
                                <div class="art-postcontent">
                                            <br />
                                            <table class="art-article" border="0" cellspacing="0" cellpadding="0">
                                                  <tr>
                                                    <td>VNINDEX <span style="margin: 0px 30px 0px 30px; "><?php foreach($this->vnindex as $vnid): ?><?php echo round($vnid->getClose(), 1); ?></span><span style="color: green; "><?php echo round((($vnid->getClose()-$vnid->getOpen())/($vnid->getOpen()))*100, 2) . "%"; ?></span><?php endforeach; ?></td>
                                                    <td rowspan="6"><img width="220px" src="<?php echo $this->baseUrl() ?>/chiso/graph1" /></td>
                                                    <td rowspan="6">&nbsp;</td>
                                                    <td>HNXINDEX <span style="margin: 0px 30px 0px 30px; "><?php foreach($this->hnxindex as $hnxid): ?><?php echo round($hnxid->getClose(), 1); ?></span><span style="color: green; "><?php echo round((($hnxid->getClose()-$hnxid->getOpen())/($hnxid->getOpen()))*100, 2) . "%"; ?></span><?php endforeach; ?></td>
                                                    <td rowspan="6"><img width="220px" src="<?php echo $this->baseUrl() ?>/chiso/graph2" /></td>
                                                  </tr>
                                                  <tr>
                                                    <td>CP tăng trần</td>
                                                    <td>data</td>
                                                  </tr>
                                                  <tr>
                                                    <td>CP tăng</td>
                                                    <td>data</td>
                                                  </tr>
                                                  <tr>
                                                    <td>CP =</td>
                                                    <td>data</td>
                                                  </tr>
                                                  <tr>
                                                    <td>CP giảm</td>
                                                    <td>data</td>
                                                  </tr>
                                                  <tr>
                                                    <td>CP giảm sàn</td>
                                                    <td>data</td>
                                                  </tr>
                                            </table>
                                            <br />
                                            <table>
                                                <tr>
                                                    <td><table class="art-article" border="0" cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                <th colspan="4">Top Movers UP 1</th>
                                                            </tr>
<?php
    //--- 
    $today = mysql_result(mysql_query("SELECT max(`date`) FROM `index_growth`"),0,0);
    
    //--- HOSE
    
	$count = mysql_result(mysql_query("SELECT COUNT(`code`) FROM `company` WHERE `stock_exchange`='HOSE'"),0,0);
    $query = mysql_query("SELECT `code` FROM `company` WHERE `stock_exchange`='HOSE'");
    $arr = array();
    for($i = 0; $i < $count ; $i ++)
    {
        $arr[] = "'".mysql_result($query,$i,0)."'";
    }
    $a = mysql_query("SELECT SUM(`von_thi_truong`) FROM `cal_risk` WHERE `stock_code` in (".implode($arr,",").")");
    $vn_von_tt = mysql_result($a,0,0);
    
    $sql = mysql_query("SELECT `stock_code`,`thay_doi`*(`von_thi_truong`/$vn_von_tt) `at`,`thay_doi` FROM `cal_risk` WHERE `date`='$today' AND `stock_code` in (".implode($arr,",").") order by `at` DESC LIMIT 0,5");
    $a_rr = array();
    for($i=0; $i <5; $i++)
    {
        for($j = 0; $j <3 ; $j++)
        {
			
            $a_rr[$i][$j] = mysql_result($sql,$i,$j);
        }
    }
    
    $sql_ = mysql_query("SELECT `stock_code`,`thay_doi`*(`von_thi_truong`/$vn_von_tt) `at`,`thay_doi` FROM `cal_risk` WHERE `date`='$today' AND `stock_code` in (".implode($arr,",").") order by `at` ASC LIMIT 0,5");
    $a_rr_2 = array();
    for($i=0; $i <5; $i++)
    {
        for($j = 0; $j <3 ; $j++)
        {
			
            $a_rr_2[$i][$j] = mysql_result($sql_,$i,$j);
        }
    }
    
    //--- HASTC
    $count_b = mysql_result(mysql_query("SELECT COUNT(`code`) FROM `company` WHERE `stock_exchange`='HASTC'"),0,0);
    $query_b = mysql_query("SELECT `code` FROM `company` WHERE `stock_exchange`='HASTC'");
    $brr = array();
    for($i = 0; $i < $count_b ; $i ++)
    {
        $brr[] = "'".mysql_result($query_b,$i,0)."'";
    }
		
    $b = mysql_query("SELECT SUM(`von_thi_truong`) FROM `cal_risk` WHERE `stock_code` in (".implode($brr,",").")");
    $hn_von_tt = mysql_result($b,0,0);
    
    $sql_1 = mysql_query("SELECT `stock_code`,`thay_doi`*(`von_thi_truong`/$hn_von_tt) `at`,`thay_doi` FROM `cal_risk` WHERE `date`='$today' AND `stock_code` in (".implode($brr,",").") order by `at` DESC LIMIT 0,5");
    $b_rr = array();
    for($i=0; $i <5; $i++)
    {
        for($j = 0; $j <3 ; $j++)
        {
			
            $b_rr[$i][$j] = mysql_result($sql_1,$i,$j);
        }
    }
    
    $sql_2 = mysql_query("SELECT `stock_code`,`thay_doi`*(`von_thi_truong`/$hn_von_tt) `at`,`thay_doi` FROM `cal_risk` WHERE `date`='$today' AND `stock_code` in (".implode($brr,",").") order by `at` ASC LIMIT 0,5");
    $b_rr_2 = array();
    for($i=0; $i <5; $i++)
    {
        for($j = 0; $j <3 ; $j++)
        {
			
            $b_rr_2[$i][$j] = mysql_result($sql_2,$i,$j);
        }
    }
    
    
?>
                                                            <tr>
                                                                <td><?php for($i = 1; $i <= 5; $i++)echo $i."<br>"; ?> </td>
                                                                <td>
                                                                    <?php
                                                                        for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo $a_rr[$i][0]."<br>";
                                                                        	}	
                                                                    ?>
                                                                </td>
                                                                <td><?php
                                                                        for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo round(($a_rr[$i][2]*100),1)."%"."<br>";
                                                                        	}
                                                                    ?></td>
                                                                <td>
                                                                    <?php
                                                                        for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo round(($a_rr[$i][1]*100),2)."%"."<br>";
                                                                        	}
                                                                    ?>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                    <td><table class="art-article" border="0" cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                <th colspan="4">Top Movers DOWN</th>
                                                            </tr>
                                                            <tr>
                                                                <td><?php for($i = 1; $i <= 5; $i++)echo $i."<br>"; ?></td>
                                                                <td><?php
                                                                        for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo $a_rr_2[$i][0]."<br>";
                                                                        	}	
                                                                    ?>
                                                                </td>
                                                                <td><?php
                                                                        for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo round(($a_rr_2[$i][2]*100),1)."%"."<br>";
                                                                        	}
                                                                    ?></td>
                                                                <td> <?php
                                                                        for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo round(($a_rr_2[$i][1]*100),2)."%"."<br>";
                                                                        	}
                                                                    ?>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                    <td><table class="art-article" border="0" cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                <th colspan="4">Top Movers UP</th>
                                                            </tr>
                                                            <tr>
                                                                <td><?php for($i = 1; $i <= 5; $i++)echo $i."<br>"; ?></td>
                                                                <td>
                                                                    <?php 
                                                                    for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo $b_rr[$i][0]."<br>";
                                                                        	}
                                                                     ?>
                                                                </td>
                                                                <td><?php for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo round(($b_rr[$i][2]*100),1)."%"."<br>";
                                                                        	} 
                                                                    ?></td>
                                                                <td><?php for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo round(($b_rr[$i][1]*100),2)."%"."<br>";
                                                                        	} 
                                                                    ?>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                    <td><table class="art-article" border="0" cellspacing="0" cellpadding="0">
                                                            <tr>
                                                                <th colspan="4">Top Movers DOWN</th>
                                                            </tr>
                                                            <tr>
                                                                <td><?php for($i = 1; $i <= 5; $i++)echo $i."<br>"; ?></td>
                                                                <td> <?php 
                                                                    for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo $b_rr_2[$i][0]."<br>";
                                                                        	}
                                                                     ?></td>
                                                                <td><?php for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo round(($b_rr_2[$i][2]*100),1)."%"."<br>";
                                                                        	} 
                                                                    ?></td>
                                                                <td><?php for($i=0; $i <5; $i++)
                                                                        	{
                                                                        		echo round(($b_rr_2[$i][1]*100),2)."%"."<br>";
                                                                        	} 
                                                                    ?>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                            <br />
                                            <table class="art-article" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                    <td><img src="<?php echo $this->baseUrl() ?>/chiso/graph3" /></td>
                                                    <td><img src="<?php echo $this->baseUrl() ?>/chiso/graph4" /></td>
                                                </tr>
                                            </table>
                                            <br />
                                            <?php /*$sum = 0;
                                                  foreach($this->hnx as $h):
                                                  if($h->getIndex() == "HOSE"):
                                                    $value = $h->getVonThiTruong();
                                                    $sum += $value;
                                                  endif;
                                                  endforeach;
                                            echo "Tổng vốn thị trường HNXINDEX:" . $sum;*/
                                            ?>
                                        </div>
                                        <div class="cleared"></div>
                            </div>                            
                            		<div class="cleared"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>